package day05_api.com.itheima.d5_regex;

public class Regex_Test1 {
    public static void main(String[] args) {

        System.out.println("checkQQ(\"23423423423ab\") = " + checkQQ("23423423423ab"));
        System.out.println("checkQQ2(\"23423423423ab\") = " + checkQQ2("23423423423ab"));
        System.out.println("checkQQ(\"23423423423\") = " + checkQQ("23423423423"));
        System.out.println("checkQQ2(\"23423423423\") = " + checkQQ2("23423423423"));
    }
    public static boolean checkQQ2(String qq){
        if (qq != null && qq.matches("[1-9]\\d{4,}")){
            return true;
        }
        return false;
    }
    public static boolean checkQQ(String qq){
        if (qq == null){
            return false;
        }
        if (qq.length() < 5){
            return false;
        }
        char c = qq.charAt(0);
        if (!(c >= '1' && c <= '9')){
            return false;
        }
        for (int i = 1; i < qq.length(); i++) {
            char c1 = qq.charAt(i);
            if (!(c1 >= '0' && c1 <= '9')){
                return false;
            }
        }
        return true;
    }
}
